<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="java.sql.*"%>
<%@page import="org.edu.system.DBConnect"%>
<!DOCTYPE html>
<html>
<head>
<link href="./bootstrap/css/bootstrap.min.css" rel="stylesheet">
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<br>
<%
request.setCharacterEncoding("utf-8");
String stype = request.getParameter("stype");
String context = request.getParameter("context");
System.out.println(stype);
System.out.println(context);
String sql_select = "";
String radioString = request.getParameter("radio");
System.out.println(radioString);
if(radioString.equals("Simyes")){
	if(stype.equals("教师id")){
		sql_select = " SELECT * FROM teacher WHERE tc_id LIKE '%" + context + "%'";
	}else if(stype.equals("教师姓名")){
		sql_select = " SELECT * FROM teacher WHERE tc_name LIKE '%" + context + "%'";
	}else if(stype.equals("教师性别")){
		sql_select = " SELECT * FROM teacher WHERE tc_gender LIKE '%" + context + "%'";
	}else if(stype.equals("所属院校")){
		sql_select = " SELECT * FROM teacher WHERE tc_college LIKE '%" + context + "%'";
	}else if(stype.equals("教师电话")){
		sql_select = " SELECT * FROM teacher WHERE tc_phone LIKE '%" + context + "%'";
	}else if(stype.equals("教师身份证")){
		sql_select = " SELECT * FROM teacher WHERE tc_identity LIKE '%" + context + "%'";
	}else if(stype.equals("教师居住地")){
		sql_select = " SELECT * FROM teacher WHERE tc_location LIKE '%" + context + "%'";
	}
}else if(radioString.equals("Simno")){
	if(stype.equals("教师ID")){
		sql_select = " SELECT * FROM teacher WHERE tc_id = '" + context + "'";
	}else if(stype.equals("教师姓名")){
		sql_select = " SELECT * FROM teacher WHERE tc_name = '" + context + "'";
	}else if(stype.equals("教师性别")){
		sql_select = " SELECT * FROM teacher WHERE tc_gender = '" + context + "'";
	}else if(stype.equals("所属院校")){
		sql_select = " SELECT * FROM teacher WHERE tc_college = '" + context + "'";
	}else if(stype.equals("教师电话")){
		sql_select = " SELECT * FROM teacher WHERE tc_phone = '" + context + "'";
	}else if(stype.equals("教师身份证")){
		sql_select = " SELECT * FROM teacher WHERE tc_identity = '" + context + "'";
	}else if(stype.equals("教师居住地")){
		sql_select = " SELECT * FROM teacher WHERE tc_location = '" + context + "'";
	}
}
System.out.println(sql_select);
try{
	Connection con = DBConnect.getCon();
	System.out.println(sql_select);
	PreparedStatement pst = con.prepareStatement(sql_select);
	ResultSet rs = pst.executeQuery();
	System.out.println(pst);
	System.out.println(rs);
	%>
	<table border=“1” class="table table-striped table-bordered">
		<tr>
			<td><font size="2">教师id</font></td>
			<td><font size="2">教师名称</font></td>
			<td><font size="2">教师性别</font></td>
			<td><font size="2">教师密码</font></td>
			<td><font size="2">所属院系</font></td>
			<td><font size="2">手机号码</font></td>
			<td><font size="2">身份证信息</font></td>
			<td colspan="2" align="center"><font size="2">数据操作</font></td>
		</tr>
		<%
			while(rs.next()){
				System.out.println(rs.getString("tc_id"));
		%>
		<tr>
			<td><font size="2"><%= rs.getString("tc_id") %></font></td>
			<td><font size="2"><%= rs.getString("tc_name") %></font></td>
			<td><font size="2"><%= rs.getString("tc_passwd") %></font></td>
			<td><font size="2"><%= rs.getString("tc_gender") %></font></td>
			<td><font size="2"><%= rs.getString("tc_college") %></font></td>
			<td><font size="2"><%= rs.getString("tc_phone") %></font></td>
			<td><font size="2"><%= rs.getString("tc_identity") %></font></td>
			<td><input type="button" class="btn btn-danger btn-xs" value="删除"
				onclick="javawwscript:if(confirm('确认删除该记录？')){location='adm_teacher_delete.jsp?id=<%=rs.getString("tc_id")%>'}" />
			</td>
			<td><input type="button" class="btn btn-primary btn-xs" value="更新"
				onclick="javawwscript:if(confirm('确认修改该记录？')){location='adm_teacher_update.jsp?id=<%=rs.getString("tc_id")%>'}" />
			</td>
		</tr>
		<%
			}
			} catch (Exception e) {
				System.out.println("执行查询："+sql_select);
				out.println(e);
			}
		%>
	</table>
	<br>
</body>
</html>